<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Action Pattern Clauses</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Action Pattern Clauses' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">if</a></li><li><a href="index.html#4">Chapter 4: Actions</a></li><li><b>Action Pattern Clauses</b></li></ul></div>
<p class="purpose">Pattern-matches on individual nouns in an action are called clauses.</p>

<ul class="toc"><li><a href="4-apc.html#SP1">&#167;1. Clause IDs</a></li><li><a href="4-apc.html#SP3">&#167;3. Clauses and their ordering</a></li><li><a href="4-apc.html#SP9">&#167;9. Clause options</a></li><li><a href="4-apc.html#SP12">&#167;12. Actor options</a></li><li><a href="4-apc.html#SP14">&#167;14. Action variable clauses</a></li><li><a href="4-apc.html#SP15">&#167;15. Aspects</a></li><li><a href="4-apc.html#SP19">&#167;19. Specificity</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Clause IDs.</b>Clauses come in types, each with their own ID. Some are hard-wired into
the compiler: <span class="extract"><span class="extract-syntax">IN_THE_PRESENCE_OF_AP_CLAUSE</span></span>, for example. Others arise
from Inform source text adding optional clauses to actions which are based
on matching action variables: see <a href="4-av.html" class="internal">Action Variables</a>.
</p>

<p class="commentary">The set of clauses in an <a href="4-ap2.html#SP3" class="internal">action_pattern</a> is stored as a linked list
of <a href="4-apc.html#SP3" class="internal">ap_clause</a> objects. Clauses must be listed in increasing ID order,
and cannot contain two clauses with the same ID. The ID numbers will either
be one of the <span class="extract"><span class="extract-syntax">*_AP_CLAUSE</span></span> enumerated values, which are clauses where the
Inform compiler has to do something special involving them, or else will
be determined by <a href="4-apc.html#SP2" class="internal">APClauses::clause_ID_for_action_variable</a> for matching
action variable clauses.
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">PARAMETRIC_AP_CLAUSE</span><span class="plain-syntax"> </span><span class="identifier-syntax">from</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">ACTOR_AP_CLAUSE</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">NOUN_AP_CLAUSE</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">SECOND_AP_CLAUSE</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">IN_AP_CLAUSE</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">IN_THE_PRESENCE_OF_AP_CLAUSE</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">WHEN_AP_CLAUSE</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">TAIL_AP_CLAUSE</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>There is no significance to the IDs returned by this function except that
they must all be different from each other and from all of the <span class="extract"><span class="extract-syntax">*_AP_CLAUSE</span></span>
values.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::clause_ID_for_action_variable</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">APClauses::clause_ID_for_action_variable</span></span>:<br/><a href="4-apc.html#SP14">&#167;14</a><br/>Action Name Lists - <a href="4-anl.html#SP40">&#167;40</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">shared_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stv</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">D</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">PluginCalls::divert_AP_clause_ID</span><span class="plain-syntax">(</span><span class="identifier-syntax">stv</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">D</span><span class="plain-syntax">); </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">D</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">oid</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax"> + </span><span class="identifier-syntax">stv</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">owner</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">allocation_id</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">off</span><span class="plain-syntax"> = </span><span class="identifier-syntax">SharedVariables::get_index</span><span class="plain-syntax">(</span><span class="identifier-syntax">stv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">1000</span><span class="plain-syntax">*</span><span class="identifier-syntax">oid</span><span class="plain-syntax"> + </span><span class="identifier-syntax">off</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::write_clause_ID</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">APClauses::write_clause_ID</span></span>:<br/><a href="4-apc.html#SP11">&#167;11</a><br/>Action Name Lists - <a href="4-anl.html#SP27">&#167;27</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">shared_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stv</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">PARAMETRIC_AP_CLAUSE:</span><span class="plain-syntax">         </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"parameter"</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">ACTOR_AP_CLAUSE:</span><span class="plain-syntax">              </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"actor"</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">NOUN_AP_CLAUSE:</span><span class="plain-syntax">               </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"noun"</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">SECOND_AP_CLAUSE:</span><span class="plain-syntax">             </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"second"</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">IN_AP_CLAUSE:</span><span class="plain-syntax">                 </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"in"</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">IN_THE_PRESENCE_OF_AP_CLAUSE:</span><span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"in-presence"</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">WHEN_AP_CLAUSE:</span><span class="plain-syntax">               </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"when"</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">TAIL_AP_CLAUSE:</span><span class="plain-syntax">               </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"tail"</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">PluginCalls::write_AP_clause_ID</span><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">stv</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"{"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">NonlocalVariables::write</span><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">SharedVariables::get_variable</span><span class="plain-syntax">(</span><span class="identifier-syntax">stv</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"}"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Clauses and their ordering.</b>A single clause is an instance of:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">clause_ID</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">shared_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stv_to_match</span><span class="plain-syntax">; </span><span class="comment-syntax"> can be </span><span class="extract"><span class="extract-syntax">NULL</span></span><span class="comment-syntax"> for some built-in clause IDs</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">clause_spec</span><span class="plain-syntax">; </span><span class="comment-syntax"> what the pattern says about this value</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">clause_options</span><span class="plain-syntax">; </span><span class="comment-syntax"> a bitmap of flags: see below</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">next</span><span class="plain-syntax">; </span><span class="comment-syntax"> in the linked list of clauses for an action pattern</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure ap_clause is accessed in 2/ri, 3/tm, 3/scn, 3/ts, 3/mhr, 4/ap, 4/av, 4/ap2, 4/anl, 4/pc, 4/ea, 4/gng, 5/us, 6/db, 6/dl, 6/dc and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>This loop conveniently runs through the clauses for <span class="extract"><span class="extract-syntax">ap</span></span>:
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="identifier-syntax">LOOP_OVER_AP_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">var</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">var</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">ap</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ap_clauses</span><span class="plain-syntax">):</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="identifier-syntax">var</span><span class="plain-syntax">; </span><span class="identifier-syntax">var</span><span class="plain-syntax"> = </span><span class="identifier-syntax">var</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">)</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>The list is stored in increasing order of clause ID. The only way to add new
clauses is with the following, which finds clause <span class="extract"><span class="extract-syntax">C</span></span> if it exists, and if not
either returns <span class="extract"><span class="extract-syntax">NULL</span></span> or creates clause <span class="extract"><span class="extract-syntax">C</span></span> (inserting at the correct list
position), depending on whether <span class="extract"><span class="extract-syntax">make</span></span> is set.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="function-syntax">APClauses::find_clause</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">APClauses::find_clause</span></span>:<br/><a href="4-apc.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">make</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">last</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER_AP_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> == </span><span class="identifier-syntax">C</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">make</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="4-apc.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Make a new clause</span><span class="named-paragraph-number">5.1</span></a></span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">last</span><span class="plain-syntax"> = </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">make</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="4-apc.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Make a new clause</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">make</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"cannot make clause in null AP"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5_1" class="paragraph-anchor"></a><b>&#167;5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Make a new clause</span><span class="named-paragraph-number">5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">new_apoc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">new_apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax"> = </span><span class="identifier-syntax">C</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">new_apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">new_apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">new_apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_options</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">last</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">ap</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ap_clauses</span><span class="plain-syntax"> = </span><span class="identifier-syntax">new_apoc</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">last</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">new_apoc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">new_apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax"> = </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">new_apoc</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-apc.html#SP5">&#167;5</a> (twice).</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>A more descriptive way to call this function:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="function-syntax">APClauses::clause</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">APClauses::clause</span></span>:<br/><a href="4-apc.html#SP7">&#167;7</a>, <a href="4-apc.html#SP12">&#167;12</a>, <a href="4-apc.html#SP13">&#167;13</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-apc.html#SP5" class="function-link"><span class="function-syntax">APClauses::find_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="function-syntax">APClauses::ensure_clause</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">APClauses::ensure_clause</span></span>:<br/><a href="4-apc.html#SP7">&#167;7</a>, <a href="4-apc.html#SP12">&#167;12</a>, <a href="4-apc.html#SP13">&#167;13</a>, <a href="4-apc.html#SP14">&#167;14</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-apc.html#SP5" class="function-link"><span class="function-syntax">APClauses::find_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>Each clause contains a specification. Note that not providing a clause is
almost the same thing as providing one with specification <span class="extract"><span class="extract-syntax">NULL</span></span>. But only
almost, because there could also be options set on it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="function-syntax">APClauses::spec</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">APClauses::spec</span></span>:<br/><a href="4-apc.html#SP19">&#167;19</a><br/>Action Patterns - <a href="4-ap2.html#SP10">&#167;10</a><br/>Parse Action Patterns - <a href="4-pap.html#SP6">&#167;6</a><br/>Explicit Actions - <a href="4-ea.html#SP2">&#167;2</a>, <a href="4-ea.html#SP3">&#167;3</a><br/>Named Action Patterns - <a href="4-nap.html#SP2">&#167;2</a><br/>Going - <a href="4-gng.html#SP8">&#167;8</a>, <a href="4-gng.html#SP9">&#167;9</a>, <a href="4-gng.html#SP15">&#167;15</a>, <a href="4-gng.html#SP16">&#167;16</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP6" class="function-link"><span class="function-syntax">APClauses::clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">)?(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax">):</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::set_spec</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">APClauses::set_spec</span></span>:<br/>Action Patterns - <a href="4-ap2.html#SP6">&#167;6</a><br/>Parse Action Patterns - <a href="4-pap.html#SP8_1">&#167;8.1</a>, <a href="4-pap.html#SP8_2">&#167;8.2</a>, <a href="4-pap.html#SP14_1">&#167;14.1</a><br/>Parse Clauses - <a href="4-pc.html#SP1_4">&#167;1.4</a><br/>Going - <a href="4-gng.html#SP8">&#167;8</a>, <a href="4-gng.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">val</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP6" class="function-link"><span class="function-syntax">APClauses::clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">) </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">val</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP6" class="function-link"><span class="function-syntax">APClauses::ensure_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">val</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>And this uses the <a href="../values-module/5-dsh.html" class="internal">Dash (in values)</a> typechecker to validate that a specification
makes sense in a given clause:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::validate</span><span class="plain-syntax">(</span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Dash::validate_parameter</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. Clause options.</b>The clause options are a bitmap. Some are meaningful only for one or two
clauses.
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">ALLOW_REGION_AS_ROOM_APCOPT</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">ACTOR_IS_NOT_PLAYER_APCOPT</span><span class="plain-syntax">  </span><span class="constant-syntax">2</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">REQUEST_APCOPT</span><span class="plain-syntax">              </span><span class="constant-syntax">4</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::opt</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">APClauses::opt</span></span>:<br/><a href="4-apc.html#SP11">&#167;11</a>, <a href="4-apc.html#SP12">&#167;12</a>, <a href="4-apc.html#SP13">&#167;13</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">opt</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_options</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">opt</span><span class="plain-syntax">) != </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::set_opt</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">APClauses::set_opt</span></span>:<br/><a href="4-apc.html#SP12">&#167;12</a>, <a href="4-apc.html#SP13">&#167;13</a><br/>Going - <a href="4-gng.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">opt</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no such apoc"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_options</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">opt</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_options</span><span class="plain-syntax"> += </span><span class="identifier-syntax">opt</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::clear_opt</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">APClauses::clear_opt</span></span>:<br/><a href="4-apc.html#SP13">&#167;13</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">opt</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no such apoc"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_options</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">opt</span><span class="plain-syntax">) </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_options</span><span class="plain-syntax"> -= </span><span class="identifier-syntax">opt</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>We can now write:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::write</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">APClauses::write</span></span>:<br/>Action Patterns - <a href="4-ap2.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_AP_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">++ &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">" "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="4-apc.html#SP2" class="function-link"><span class="function-syntax">APClauses::write_clause_ID</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax">, </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">": "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">instance</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::object_exactly_described_if_any</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">I</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Instances::write</span><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Specifications::is_description</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">pcalc_prop</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prop</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::to_proposition</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Propositions::write</span><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">prop</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%P"</span><span class="plain-syntax">, </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-apc.html#SP10" class="function-link"><span class="function-syntax">APClauses::opt</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="constant-syntax">ALLOW_REGION_AS_ROOM_APCOPT</span><span class="plain-syntax">)) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"[allow-region]"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-apc.html#SP10" class="function-link"><span class="function-syntax">APClauses::opt</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="constant-syntax">ACTOR_IS_NOT_PLAYER_APCOPT</span><span class="plain-syntax">)) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"[not-player]"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-apc.html#SP10" class="function-link"><span class="function-syntax">APClauses::opt</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="constant-syntax">REQUEST_APCOPT</span><span class="plain-syntax">)) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"[request]"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. Actor options.</b>Two options are used with the actor clause (only), reflecting the unusual ways
it can be used.
</p>

<p class="commentary">First, the following is for action patterns like "someone taking the medallion".
Here the requirement on the actor is not \({\it person}(c_a)\) but instead forces
\(c_a\) not to be the player. The principled thing might be to set the <span class="extract"><span class="extract-syntax">clause_spec</span></span>
to the proposition \({\it person}(c_a)\land c_a\neq {\it player}\), but that would
be annoying to test for. So we give it an option flag instead:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::make_actor_anyone_except_player</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">APClauses::make_actor_anyone_except_player</span></span>:<br/>Parse Action Patterns - <a href="4-pap.html#SP8_3">&#167;8.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP6" class="function-link"><span class="function-syntax">APClauses::ensure_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="constant-syntax">ACTOR_AP_CLAUSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-apc.html#SP10" class="function-link"><span class="function-syntax">APClauses::set_opt</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="constant-syntax">ACTOR_IS_NOT_PLAYER_APCOPT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::actor_is_anyone_except_player</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">APClauses::actor_is_anyone_except_player</span></span>:<br/>Explicit Actions - <a href="4-ea.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP6" class="function-link"><span class="function-syntax">APClauses::clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="constant-syntax">ACTOR_AP_CLAUSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-apc.html#SP10" class="function-link"><span class="function-syntax">APClauses::opt</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="constant-syntax">ACTOR_IS_NOT_PLAYER_APCOPT</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. </b>Secondly, when the following is set, the action is a request. Thus "asking
Matilda to try taking the medallion" would have this option set, but "Matilda
taking the medallion" would not.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::set_request</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">APClauses::set_request</span></span>:<br/>Parse Action Patterns - <a href="4-pap.html#SP8_1">&#167;8.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP6" class="function-link"><span class="function-syntax">APClauses::ensure_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="constant-syntax">ACTOR_AP_CLAUSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-apc.html#SP10" class="function-link"><span class="function-syntax">APClauses::set_opt</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="constant-syntax">REQUEST_APCOPT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::clear_request</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">APClauses::clear_request</span></span>:<br/>Parse Action Patterns - <a href="4-pap.html#SP8_2">&#167;8.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP6" class="function-link"><span class="function-syntax">APClauses::ensure_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="constant-syntax">ACTOR_AP_CLAUSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="4-apc.html#SP10" class="function-link"><span class="function-syntax">APClauses::clear_opt</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="constant-syntax">REQUEST_APCOPT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::is_request</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">APClauses::is_request</span></span>:<br/>Explicit Actions - <a href="4-ea.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP6" class="function-link"><span class="function-syntax">APClauses::clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="constant-syntax">ACTOR_AP_CLAUSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-apc.html#SP10" class="function-link"><span class="function-syntax">APClauses::opt</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="constant-syntax">REQUEST_APCOPT</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. Action variable clauses.</b>The following functions deal only with clauses which are attached to action
variables:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::set_action_variable_spec</span><button class="popup" onclick="togglePopup('usagePopup17')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup17">Usage of <span class="code-font"><span class="function-syntax">APClauses::set_action_variable_spec</span></span>:<br/>Parse Clauses - <a href="4-pc.html#SP1_4">&#167;1.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="identifier-syntax">shared_variable</span><span class="plain-syntax"> *</span><span class="identifier-syntax">stv</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">stv</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no shared variable for apoc"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP2" class="function-link"><span class="function-syntax">APClauses::clause_ID_for_action_variable</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">stv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP6" class="function-link"><span class="function-syntax">APClauses::ensure_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax"> = </span><span class="identifier-syntax">stv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax"> = </span><span class="identifier-syntax">spec</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">PluginCalls::new_action_variable_clause</span><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="function-syntax">APClauses::advance_to_next_av_clause</span><span class="plain-syntax">(</span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)) </span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::has_action_variable_clauses</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) &amp;&amp; (</span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::advance_to_next_av_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ap_clauses</span><span class="plain-syntax">))) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::count_action_variable_clauses</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ap</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::advance_to_next_av_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ap_clauses</span><span class="plain-syntax">); </span><span class="identifier-syntax">apoc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">apoc</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::advance_to_next_av_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">n</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::compare_specificity_of_av_clauses</span><button class="popup" onclick="togglePopup('usagePopup18')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup18">Usage of <span class="code-font"><span class="function-syntax">APClauses::compare_specificity_of_av_clauses</span></span>:<br/><a href="4-apc.html#SP19">&#167;19</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">rct1</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::count_action_variable_clauses</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">rct2</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::count_action_variable_clauses</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap2</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rct1</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">rct2</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rct1</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">rct2</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rct1</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc1</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::advance_to_next_av_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ap_clauses</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        *</span><span class="identifier-syntax">apoc2</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::advance_to_next_av_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ap_clauses</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">apoc1</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">apoc2</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">off1</span><span class="plain-syntax"> = </span><span class="identifier-syntax">SharedVariables::get_index</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">off2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">SharedVariables::get_index</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">stv_to_match</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">off1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">off2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Specifications::compare_specificity</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">apoc1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">apoc2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax"> != </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">apoc1</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::advance_to_next_av_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">apoc2</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::advance_to_next_av_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">off1</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">off2</span><span class="plain-syntax">) </span><span class="identifier-syntax">apoc1</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::advance_to_next_av_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">off1</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">off2</span><span class="plain-syntax">) </span><span class="identifier-syntax">apoc2</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::advance_to_next_av_clause</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. Aspects.</b>Clauses are divided into groups called "aspects", each of which has an ID
in the <span class="extract"><span class="extract-syntax">*_APCA</span></span> enumeration.
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">PARAMETRIC_APCA</span><span class="plain-syntax"> </span><span class="identifier-syntax">from</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">PRIMARY_APCA</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">IN_APCA</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">PRESENCE_APCA</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">WHEN_APCA</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">TAIL_APCA</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">MISC_APCA</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::aspect</span><button class="popup" onclick="togglePopup('usagePopup19')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup19">Usage of <span class="code-font"><span class="function-syntax">APClauses::aspect</span></span>:<br/><a href="4-apc.html#SP16">&#167;16</a>, <a href="4-apc.html#SP17">&#167;17</a>, <a href="4-apc.html#SP18">&#167;18</a><br/>Explicit Actions - <a href="4-ea.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">ap_clause</span><span class="plain-syntax"> *</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">PARAMETRIC_AP_CLAUSE:</span><span class="plain-syntax">         </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">PARAMETRIC_APCA</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">ACTOR_AP_CLAUSE:</span><span class="plain-syntax">              </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">PRIMARY_APCA</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">NOUN_AP_CLAUSE:</span><span class="plain-syntax">               </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">PRIMARY_APCA</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">SECOND_AP_CLAUSE:</span><span class="plain-syntax">             </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">PRIMARY_APCA</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">IN_AP_CLAUSE:</span><span class="plain-syntax">                 </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">IN_APCA</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">IN_THE_PRESENCE_OF_AP_CLAUSE:</span><span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">PRESENCE_APCA</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">WHEN_AP_CLAUSE:</span><span class="plain-syntax">               </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">WHEN_APCA</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">TAIL_AP_CLAUSE:</span><span class="plain-syntax">               </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">TAIL_APCA</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">PluginCalls::aspect_of_AP_clause_ID</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_ID</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">rv</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">MISC_APCA</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. </b>How many clauses with aspect <span class="extract"><span class="extract-syntax">A</span></span> does the pattern have?
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::number_with_aspect</span><button class="popup" onclick="togglePopup('usagePopup20')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup20">Usage of <span class="code-font"><span class="function-syntax">APClauses::number_with_aspect</span></span>:<br/>Going - <a href="4-gng.html#SP16">&#167;16</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">A</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_AP_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-apc.html#SP15" class="function-link"><span class="function-syntax">APClauses::aspect</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">) == </span><span class="identifier-syntax">A</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">c</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. </b>How many different aspects can be found among the pattern's clauses?
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::count_aspects</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">asps</span><span class="plain-syntax">[</span><span class="identifier-syntax">NO_DEFINED_APCA_VALUES</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">a</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">NO_DEFINED_APCA_VALUES</span><span class="plain-syntax">; </span><span class="identifier-syntax">a</span><span class="plain-syntax">++) </span><span class="identifier-syntax">asps</span><span class="plain-syntax">[</span><span class="identifier-syntax">a</span><span class="plain-syntax">] = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_AP_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap</span><span class="plain-syntax">) </span><span class="identifier-syntax">asps</span><span class="plain-syntax">[</span><a href="4-apc.html#SP15" class="function-link"><span class="function-syntax">APClauses::aspect</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">)] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">ap</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">duration</span><span class="plain-syntax">)) </span><span class="identifier-syntax">asps</span><span class="plain-syntax">[</span><span class="constant-syntax">WHEN_APCA</span><span class="plain-syntax">] = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">a</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">NO_DEFINED_APCA_VALUES</span><span class="plain-syntax">; </span><span class="identifier-syntax">a</span><span class="plain-syntax">++) </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">asps</span><span class="plain-syntax">[</span><span class="identifier-syntax">a</span><span class="plain-syntax">]) </span><span class="identifier-syntax">c</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b>There are major limitations on which action patterns can be tested in
the past tense. They can only specify primary clauses, and then only with
definite values or descriptions of specific objects.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::viable_in_past_tense</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-ea.html#SP4" class="function-link"><span class="function-syntax">ExplicitActions::ap_overspecific</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_AP_CLAUSES</span><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-apc.html#SP15" class="function-link"><span class="function-syntax">APClauses::aspect</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">) == </span><span class="constant-syntax">PRIMARY_APCA</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-apc.html#SP18" class="function-link"><span class="function-syntax">APClauses::pta_acceptable</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">apoc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">clause_spec</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::pta_acceptable</span><span class="plain-syntax">(</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">spec</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Specifications::is_description</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Specifications::object_exactly_described_if_any</span><span class="plain-syntax">(</span><span class="identifier-syntax">spec</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. Specificity.</b>See <a href="4-ap2.html#SP10" class="internal">ActionPatterns::compare_specificity</a>, which calls this to look at clauses.
The code here looks innocent enough but has significant implications for rule
sorting.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::compare_specificity</span><button class="popup" onclick="togglePopup('usagePopup21')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup21">Usage of <span class="code-font"><span class="function-syntax">APClauses::compare_specificity</span></span>:<br/>Action Patterns - <a href="4-ap2.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Specifications::law</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"III.1 - Object To Which Rule Applies"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP19" class="function-link"><span class="function-syntax">APClauses::cmp_clause</span></a><span class="plain-syntax">(</span><span class="constant-syntax">PARAMETRIC_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap2</span><span class="plain-syntax">); </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">ignore_in</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="identifier-syntax">PluginCalls::compare_AP_specificity</span><span class="plain-syntax">(</span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap2</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">rv</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">ignore_in</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax"> != </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ignore_in</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Specifications::law</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"III.2.2 - Action/Where/Room Where Action Takes Place"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP19" class="function-link"><span class="function-syntax">APClauses::cmp_clause</span></a><span class="plain-syntax">(</span><span class="constant-syntax">IN_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap2</span><span class="plain-syntax">); </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">Specifications::law</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"III.2.3 - Action/Where/In The Presence Of"</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP19" class="function-link"><span class="function-syntax">APClauses::cmp_clause</span></a><span class="plain-syntax">(</span><span class="constant-syntax">IN_THE_PRESENCE_OF_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap2</span><span class="plain-syntax">); </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP14" class="function-link"><span class="function-syntax">APClauses::compare_specificity_of_av_clauses</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax"> != </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">Specifications::law</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"III.3.1 - Action/What/Second Thing Acted On"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP19" class="function-link"><span class="function-syntax">APClauses::cmp_clause</span></a><span class="plain-syntax">(</span><span class="constant-syntax">SECOND_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap2</span><span class="plain-syntax">); </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">Specifications::law</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"III.3.2 - Action/What/Thing Acted On"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP19" class="function-link"><span class="function-syntax">APClauses::cmp_clause</span></a><span class="plain-syntax">(</span><span class="constant-syntax">NOUN_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap2</span><span class="plain-syntax">); </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">Specifications::law</span><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"III.3.3 - Action/What/Actor Performing Action"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = </span><a href="4-apc.html#SP19" class="function-link"><span class="function-syntax">APClauses::cmp_clause</span></a><span class="plain-syntax">(</span><span class="constant-syntax">ACTOR_AP_CLAUSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap2</span><span class="plain-syntax">); </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rv</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::cmp_clause</span><button class="popup" onclick="togglePopup('usagePopup22')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup22">Usage of <span class="code-font"><span class="function-syntax">APClauses::cmp_clause</span></span>:<br/>Going - <a href="4-gng.html#SP16">&#167;16</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-apc.html#SP19" class="function-link"><span class="function-syntax">APClauses::cmp_clauses</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">ap2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">APClauses::cmp_clauses</span><button class="popup" onclick="togglePopup('usagePopup23')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup23">Usage of <span class="code-font"><span class="function-syntax">APClauses::cmp_clauses</span></span>:<br/>Going - <a href="4-gng.html#SP16">&#167;16</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C1</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">C2</span><span class="plain-syntax">, </span><span class="reserved-syntax">action_pattern</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ap2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Specifications::compare_specificity</span><span class="plain-syntax">(</span>
<span class="plain-syntax">        </span><a href="4-apc.html#SP7" class="function-link"><span class="function-syntax">APClauses::spec</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap1</span><span class="plain-syntax">, </span><span class="identifier-syntax">C1</span><span class="plain-syntax">), </span><a href="4-apc.html#SP7" class="function-link"><span class="function-syntax">APClauses::spec</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ap2</span><span class="plain-syntax">, </span><span class="identifier-syntax">C2</span><span class="plain-syntax">), </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="4-anl.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-im.html">1</a></li><li class="progresschapter"><a href="2-bd.html">2</a></li><li class="progresschapter"><a href="3-sm.html">3</a></li><li class="progresscurrentchapter">4</li><li class="progresssection"><a href="4-ap.html">ap</a></li><li class="progresssection"><a href="4-anaa.html">anaa</a></li><li class="progresssection"><a href="4-ak.html">ak</a></li><li class="progresssection"><a href="4-ac.html">ac</a></li><li class="progresssection"><a href="4-act.html">act</a></li><li class="progresssection"><a href="4-as.html">as</a></li><li class="progresssection"><a href="4-av.html">av</a></li><li class="progresssection"><a href="4-ann.html">ann</a></li><li class="progresssection"><a href="4-ap2.html">ap2</a></li><li class="progresssection"><a href="4-anl.html">anl</a></li><li class="progresscurrent">apc</li><li class="progresssection"><a href="4-pap.html">pap</a></li><li class="progresssection"><a href="4-pc.html">pc</a></li><li class="progresssection"><a href="4-ea.html">ea</a></li><li class="progresssection"><a href="4-nap.html">nap</a></li><li class="progresssection"><a href="4-gng.html">gng</a></li><li class="progresssection"><a href="4-rpoa.html">rpoa</a></li><li class="progresschapter"><a href="5-pp.html">5</a></li><li class="progresschapter"><a href="6-dlg.html">6</a></li><li class="progressnext"><a href="4-pap.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

